import { FilterConst } from "../../../component/gconst/FilterConst";
import { GButton } from "../../../../com/mui/controls/GButton";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { GameDefConfig } from "../../resource/GameDefConfig";
import { ColorConfig } from "../../resource/ColorConfig";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { Language } from "../../../../extend/language/Language";
import { Cache } from "../../cache/Cache";
type int = number;
//class NationalTreaCheckItem
    
    export  class NationalTreaCheckItem /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.initUI();
            return;
        }

        protected initUI(): void
        {
            this._infoTxt = new Object /* flash.text.TextField */();
            this._infoTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._infoTxt.selectable = false;
            this._infoTxt.mouseEnabled = false;
            this._infoTxt.textColor = 16777215;
            this._infoTxt.filters = [FilterConst.nameGlowFilter];
            this._infoTxt.text = "00";
            this._infoTxt.width = 100;
            this._infoTxt.height = 20;
            addChild(this._infoTxt);
            this._optBtn = new GButton();
            this._optBtn.setSize(70, 20);
            this._optBtn.label = "00";
            this._optBtn.styleName = "ButtonMini";
            this._optBtn.x = 100;
            this._optBtn.y = 0;
            this._optBtn.textField.filters = [FilterConst.nameGlowFilter];
            this._optBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onOptBtnClickHandler);
            return;
        }

        /* internal  */onOptBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.NationalTreasurePassReq, this._camp));
            return;
        }

        public updateData(arg1: int, arg2: int, arg3: Boolean=true, arg4: Boolean=true): void
        {
            this._camp = arg1;
            var loc1=GameDefConfig.instance.getECamp(arg1);
            var loc2=ColorConfig.instance.getCampColor(arg1).color;
            this._infoTxt.htmlText = HTMLUtil.addColor(loc1 + " (" + arg2 + Language.getString(27004) + ")", loc2);
            if (arg3) 
            {
                if (!contains(this._optBtn)) 
                {
                    addChild(this._optBtn);
                }
                if (arg1 != Cache.instance.role.entityInfo.camp) 
                {
                    this._optBtn.label = loc1 + Language.getString(27005);
                }
                else 
                {
                    this._optBtn.label = loc1 + Language.getString(27006);
                }
                if (arg4) 
                {
                    this._optBtn.enabled = true;
                }
                else 
                {
                    this._optBtn.label = Language.getString(27007);
                    this._optBtn.enabled = false;
                }
            }
            else if (contains(this._optBtn)) 
            {
                removeChild(this._optBtn);
            }
            return;
        }

        public dispose(): void
        {
            return;
        }

        public /* override */ get height(): number
        {
            return 20;
        }

        public /* override */ get width(): number
        {
            return 200;
        }

        protected /* var */_infoTxt: Object /* flash.text.TextField */;

        protected /* var */_optBtn: GButton;

        protected /* var */_camp: int;
    }
